import { createRouter, createWebHistory } from 'vue-router'
const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',//父路由
      name: 'Tabbar',
      component: () => import('../views/TabbarView.vue'),
      children: [ //孩子节点（路由）
        {
          path: '/',//访问路径：/
          name: 'shouye',
          component: () => import('../views/shouye.vue')
        },
        {
          path: '/fabuxianzhi',//路由地址（唯一）
          name: 'trades',      //路由名称（唯一）
          component: () => import('../views/FabuxianzhiView.vue')
        },
        {
          path: '/messagelist',
          name: 'messagelist',
          component: () => import('../views/MessagelistView.vue')
        },
        {
          path: '/personal',
          name: 'personal',
          component: () => import('../views/PersonalView.vue')
        },
        {
          path: '/:pathMatch(.*)*',
          name: 'NotFound',
          component: () => import('../views/NotFoundView.vue')
        }
      ]
    },
    {
      //id 匹配具体的（params,路径）参数，参数名id
      path: '/goods/:goodsId(\\d+)',// \d表示匹配[0-9], + 表示匹配：一个或多个
      name: 'goods',
      component: () => import('../views/GoodsView.vue'),
      props: (toRoute) => { //函数模式，设置静态值
        console.log("props.route= ", toRoute);//在 props 函数中可以接受目标路由 route 对象
        console.log(toRoute.params.goodsId)
        return { id: toRoute.params.goodsId };
      },
      meta: {
        isAuth: true, //设置当前路由是否需要用户登陆后才能访问
        title: '这是商品ID'
      }
    },
    {
      path: '/goodstype', //访问路径：/ 
      name: 'goodstype',
      component: () => import('../views/GoodsTypeView.vue')
    },
    {
      path: '/goodsdetail/:goodsId(\\d+)',
      name: 'goodsdetail',
      component: () => import('../views/GoodsDetailView.vue'),
      props: (toRoute) => {
        console.log("props.route= ", toRoute);
        console.log(toRoute.params.id)
        return { id: toRoute.params.id };
      },
      meta: {
        isAuth: true,
        title: '这是商品ID'
      }
    },
    {
      path: '/navbar/:id(\\d+)',  //路由地址（唯一）
      name: 'navbar', //路由名称（唯一）
      component: () => import('../views/NavbarView.vue'),
      props: (toRoute) => {
        console.log("props.route=", toRoute);
        console.log(toRoute.params.id);
        return { id: toRoute.params.id, title: '商品详情页' };
      },
      meta: {
        isAuth: true,
        title:'商品页面'
      }
    },
    {
      path: '/message',
      name: 'message',
      // route level code-splitting
      // this generates a separate chunk (About.[hash].js) for this route
      // which is lazy-loaded when the route is visited.
      component: () => import('../views/MessageView.vue')
    },
    {
      path: '/beforepay',
      name: 'beforepay',
      component: () => import('../views/BeforePayView.vue')
    },
    {
      path: '/paydetail/:orderNumber',
      name: 'PayDetailView',
      component: () => import('../views/PayDetailView.vue')
    },
    {
      path: '/backorder',
      name: 'backorder',
      component: () => import('../views/BackOrderView.vue')
    },
    {

      path: '/aftersend',
      name: 'aftersend',
      component: () => import('../views/AfterSendView.vue')
    },
    {

      path: '/regist',
      name: 'regist',
      // route level code-splitting
      // this generates a separate chunk (About.[hash].js) for this route
      // which is lazy-loaded when the route is visited.
      component: () => import('../views/RegisterView.vue')
    },
    {
      path: '/login',
      name: 'login',
      // route level code-splitting
      // this generates a separate chunk (About.[hash].js) for this route
      // which is lazy-loaded when the route is visited.
      component: () => import('../views/LoginView.vue')


    },
    {

      path: '/mycomment',
      name: 'mycomment',
      component: () => import('../views/MyCommentView.vue')
    },
    {
      path: '/commentsub/:orderNumber(\\d+)',
      name: 'commentsub',
      component: () => import('../views/CommentSubView.vue')
    },
    {
      path: '/selled',
      name: 'selled',
      component: () => import('../views/SelledView.vue')

    },
    {
      path: '/buy',
      name: 'buy',
      component: () => import('../views/BuyView.vue')

    },
    {
      path: '/fabusuccess',
      name: 'facu',
      component: () => import('../views/FabusuccessView.vue')
    },
    {
      path: '/mytrade',
      name: 'mytrade',
      component: () => import('../views/Mytrade.vue')
    },
    {
      path: '/address',
      name: 'address',
      component: () => import('../views/AddressView.vue')
    },
    {
      path: '/addressedit',
      name: 'addressedit',
      component: () => import('../views/AddressEditView.vue')
    },
    {
      path: '/collect',
      name: 'collect',
      component: () => import('../views/collect.vue')
    },
    {
      path: '/suborder/:orderNumber',
      name: 'suborder',
      component: () => import('../views/SubOrderView.vue')
    }, {
      path: '/returnorderinfo/:reorderId',
      name: 'returnorderinfo',
      component: () => import('../views/ReturnOrderInfoView.vue')
    },
    {
      path: '/empty',
      name: 'empty',
      component: () => import('../views/EmptyView.vue')
    },
    {
      path: '/tempty',
      name: 'tempty',
      component: () => import('../views/TabEmptyView.vue')
    },
    {
      path: '/setting',
      name: 'setting',
      component: () => import('../views/SettingView.vue')
    },
    {
      path: '/theme',
      name: 'theme',
      component: () => import('../views/ThemeView.vue')
    },
    {
      path: '/settinginfo',
      name: 'settinginfo',
      component: () => import('../views/SettingInfoView.vue')
    },
    {
      path: '/account',
      name: 'account',
      component: () => import('../views/AccountAndSecurityView.vue')
    },
    {
      path: '/aftercomment',
      name: 'aftercomment',
      component: () => import('../views/AfterCommentListView.vue')
    },
    {
      path: '/tocomment',
      name: 'tocomment',
      component: () => import('../views/ToCommentListView.vue')
    }, {
      path: '/commentlist',
      name: 'commentlist',
      component: () => import('../views/CommentListView.vue')
    },
    {
      path: '/contact',
      name: 'contact',
      component: () => import('../views/ContactView.vue')
    },
    {
      path: '/goodsdetail/:goodsId(\\d+)',
      name: 'goodsdetail',
      component: () => import('../views/GoodsDetailView.vue'),
      props: (toRoute) => {
        console.log("props.route= ", toRoute);
        console.log(toRoute.params.id)
        return { id: toRoute.params.id };
      },
      meta: {
        isAuth: true,
        title: '这是商品ID'
      }
    },

    {
      path: '/orderinf/:orderNumber',// :id匹配具体的(params,路径)参数，参数名id
      name: 'orderinf',
      component: () => import('../views/OrderInfoView.vue'),

      props: (toRoute) => {
        console.log("props.route=", toRoute);//在props函数中可以接收目标路由route对象
        console.log(toRoute.params.id)
        return { id: toRoute.params.id, title: '标题' };
      },
    },
    {
      props: (toRoute) => {
        console.log("props.route=", toRoute);//在props函数中可以接收目标路由route对象
        console.log(toRoute.params.orderNumber)
        return { orderNumber: toRoute.params.orderNumber, title: '标题' };
      },
    },
    {     
        props: (toRoute) => {
          console.log("props.route=", toRoute);//在props函数中可以接收目标路由route对象
          console.log(toRoute.params.orderNumber)
          return { orderNumber: toRoute.params.orderNumber,title: '标题' };
        },
    },
    {
      path: '/attention',
      name: 'attention',
      component: () => import('../views/AttentionView.vue')
    },
    // {
    //   path: '/addreorder',
    //   name: 'addreorder',
    //   component: () => import('../views/AddReturnOrderView.vue')
    // },
    {
      path: '/orderinfo',
      name: 'orderinfo',
      component: () => import('../views/OrderInfoView.vue')
    },
    {
      path: '/history/:userId(\\d+)',// :id匹配具体的(params,路径)参数，参数名id',
      name: 'history',
      component: () => import('../views/HistoryView.vue'),
      props: (toRoute) => {
        console.log("props.route=", toRoute);//在props函数中可以接收目标路由route对象
        console.log(toRoute.params.id)
        return { id: toRoute.params.id, title: '标题' };
      },
    },
    {
      path: '/navbar/:goodsId(\\d+)',
      name: 'navbar',
      component: () => import('../views/NavbarView.vue'),
      props: (toRoute) => {
        console.log("props.route= ", toRoute);
        console.log(toRoute.params.id)
        return { id: toRoute.params.id };
     }},
    {
      path: '/search',
      name: 'search',
      component: () => import('../views/SearchView.vue')
    },
    {
      //id 匹配具体的（params,路径）参数，参数名id
      path: '/navbar/:goodsId(\\d+)',// \d表示匹配[0-9], + 表示匹配：一个或多个
      name: 'goods',
      component: () => import('../views/GoodsView.vue'),
      props: (toRoute) => { //函数模式，设置静态值

        console.log("props.route= ", toRoute);//在 props 函数中可以接受目标路由 route 对象
        console.log(toRoute.params.goodsId)
        return { id: toRoute.params.goodsId };}
    },
    {
 //id 匹配具体的（params,路径）参数，参数名id
      path: '/navbar/:goodsId',// \d表示匹配[0-9], + 表示匹配：一个或多个
      name: 'goods',
      component: () => import('../views/GoodsView.vue'),
      props: (toRoute) => { //函数模式，设置静态值
        console.log("props.route= ",toRoute);//在 props 函数中可以接受目标路由 route 对象
        console.log(toRoute.params.goodsId)
        return {goodsId: toRoute.params.goodsId};
      },
      meta: {
        isAuth: true,
        title: '这是商品ID'
      }
    },
    {
      path: '/returnorder',
      name: 'returnorder',
      component: () => import('../views/ReturnOrderListView.vue')
    },
   {
      path: '/ackreturn',
      name: 'ackreturn',
      component: () => import('../views/SellerAckForReturnView.vue')
    }, {
      path: '/asksellerinfo/:reorderId',
      name: 'asksellerinfo',
      component: () => import('../views/ReturnOrderSellerInfoView.vue'),
      props: (toRoute) => { //函数模式，设置静态值
        console.log("props.route= ", toRoute);//在 props 函数中可以接受目标路由 route 对象
        console.log(toRoute.params.reorderId)
        return { id: toRoute.params.reorderId };
      },
    }, {
    },{
      path: '/asksellerinfo/:reorderId(\\d+)',
      name: 'asksellerinfo',
      component: () => import('../views/ReturnOrderSellerInfoView.vue'),
      props: (toRoute) => { //函数模式，设置静态值
        console.log("props.route= ", toRoute);//在 props 函数中可以接受目标路由 route 对象
        console.log(toRoute.params.reorderId)
        return { id: toRoute.params.reorderId };
      }
    }, {
      path: '/ackreturn',
      name: 'ackreturn',
      component: () => import('../views/SellerAckForReturnView.vue')
    },
    {
      path: '/fans',
      name: 'fans',
      component: () => import('../views/FansView.vue')
    }, {
      path: '/commentinfo/:commentId(\\d+)',// :id匹配具体的(params,路径)参数，参数名id
      name: 'commentinfo',
      component: () => import('../views/CommentInfoView.vue'),

      props: (toRoute) => {
        console.log("props.route=", toRoute);//在props函数中可以接收目标路由route对象
        console.log(toRoute.params.commentId)
        return { commentId: toRoute.params.commentId, title: '标题' };
      },
    },
    {
      path: '/selledxianzhi',
      name: 'selledxianzhi',
      component: () => import('../views/Selledxianzhi.vue')
    },
    {
      path: '/client',
      name: 'client',
      component: () => import('../views/ClientView.vue')
    },
  ]
})
export default router
